<template>
	<view class="content">
		<u-navbar bgColor="transparent" titleStyle="color:#fff" title="商城" leftIcon="" :placeholder="true">
		</u-navbar>
		<view class="head-swiper">
			<u-swiper height="300rpx" :radius="20" bgColor="rgba(0,0,0,0.0)" keyName="img" :list="swiperlist"
				@click="change"></u-swiper>
		</view>
		<view class="funbox">
			<view class="fun-item" @click="golist(0)">
				<view>
					<image src="/static/shop/icon1.png" mode=""></image>
				</view>
				<view class="title">
					全部订单
				</view>
			</view>
			<view class="fun-item" @click="golist(1)">
				<view>
					<image src="/static/shop/icon2.png" mode=""></image>
				</view>
				<view class="title">
					待发货
				</view>
			</view>
			<view class="fun-item" @click="golist(2)">
				<view>
					<image src="/static/shop/icon3.png" mode=""></image>
				</view>
				<view class="title">
					待收货
				</view>
			</view>
			<view class="fun-item" @click="goadd()">
				<view>
					<image src="/static/shop/icon4.png" mode=""></image>
				</view>
				<view class="title">
					地址管理
				</view>
			</view>
		</view>
		<view class="shop">
			<view class="shop-item" v-for="(item,index) in list" :key="index">
				<view class="shop-bg">
					<image :src="item.logo"></image>
				</view>
				<view class="shop-info">
					<view class="info-left">
						<view class="info-name">{{item.goods_name}}</view>
						<view class="tips">
							可使用{{item.f_name}}兑换卡
						</view>
					</view>
					<view class="info-btn" @click="goOrder(item)">
						兑换
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				swiperlist: [
					{
						img: '/static/shop/banner1.png',
						id: 8
					},
					{
						img: '/static/shop/banner2.png',
						id: 9
					},
					{
						img: '/static/shop/banner3.png',
						id: 10
					},
					{
						img: '/static/shop/banner4.png',
						id: 11
					}
				],
				info:{},
				list: [],
			}
		},
		onLoad() {
			this.shoplist()
			this.realname()
		},
		methods: {
			golist(e){
				uni.navigateTo({
					url:'/pages/shop/orderlist/index?cutt='+e
				})
			},
			goadd(){
				uni.navigateTo({
					url:'/pages/shop/address/index'
				})
			},
			realname(){
				let params = {
				
				}
				this.$Request({
					method: 'POST',
					url: '/api/Personal/myIndex',
					data: params
				}).then(res => {
					if (res.code == 1) {
						this.info = res.data.user
					}
				})
			},
			change(e) {
				if(this.info.real_name_status == 0){
					uni.showToast({
						title:'请先实名！',
						icon:'none'
					})
					this.realname()
					return
				}
				uni.navigateTo({
					url: '/pages/factory/details/index?id=' + this.swiperlist[e].id + '&isshow=false'
				})
			},
			goOrder(item) {
				uni.navigateTo({
					url: '/pages/shop/order/index?item='+encodeURIComponent(JSON.stringify(item))
				})
			},
			shoplist() {
				this.$Request({
					method: 'POST',
					url: '/api/shop/goodsList',
					data: {}
				}).then(res => {
					if (res.code == 1) {
						this.list = res.data;
					}
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #17191A;
	}
</style>
<style lang="scss" scoped>
	.content {
		min-height: 100vh;
		background-image: url('../../static/my/my-bg.png');
		background-repeat: no-repeat;
		background-size: 100% 568rpx;
		padding: 30rpx;
		.funbox{
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding-top: 30rpx;
			.fun-item{
				width: 25%;
				text-align: center;
				color: #fff;
				image{
					width: 88rpx;
					height: 88rpx;
				}
				.title{
					font-size: 26rpx;
					margin-top: 10rpx;
				}
			}
		}
		.shop {
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;
			margin-top: 20rpx;

			.shop-item {
				width: 48%;
				margin-top: 30rpx;

				.shop-bg {
					background-color: #1D2123;
					border-radius: 20rpx;
					overflow: hidden;

					image {
						width: 100%;
						height: 360rpx;
						
					}
				}

				.shop-info {
					display: flex;
					justify-content: space-between;
					margin-top: 30rpx;

					.info-left {
						.info-name {
							color: #ffffff;
							font-size: 32rpx;
							font-weight: bold;
						}

						.tips {
							font-size: 24rpx;
							color: #999;
							margin-top: 10rpx;
						}
					}

					.info-btn {
						background: linear-gradient(90deg, #C8F673 0%, #98F083 100%);
						width: 100rpx;
						height: 54rpx;
						line-height: 54rpx;
						text-align: center;
						border-radius: 10rpx;
					}
				}
			}
		}
	}
</style>